package cate.game.res.furniturecall;

import cate.common.table.d.GDSpiceCall;
import cate.game.db.mongo.kv.KvMongo;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.List;

public class FurnitureCallSPO extends KvMongo {
    @NoteField(value = "日志")
    public List<FurnitureCallLog> logs;

    @Override
    public String getKeyPrefix() {
        return KvMongo.KEY_FURNITURE_CALL_DATA;
    }

    @Override
    public void initialize() {
        if (logs == null) {
            logs = new ArrayList<>();
        }
    }

    public void addLog(String name, int rewardId) {
        FurnitureCallLog log = new FurnitureCallLog(name, rewardId);
        synchronized (logs) {
            logs.add(0, log);
            if (logs.size() > GDSpiceCall.ZONE_LOG_MAX) {
                logs.remove(logs.size() - 1);
            }
        }
    }
}
